2 Problem: 120 - Stack of flapjacks
3 Author: Andrés Mejía-Posada
4 (http://blogaritmo.factorcomun.org)
31 while (getline(cin
, s
)){
35 for (int x
; sin
>> x
; v
.push_back(x
), sol
.push_back(x
));
36 sort(sol
.begin(), sol
.end(), greater
<int>());
39 for (int i
=1; i
<v
.size(); ++i
) cout
<< " " << v
[i
];
42 reverse(v
.begin(), v
.end());
49 while (v
[i
] != sol
[llevo
]) ++i
;
51 if (i
+1 < n
) cout
<< i
+1 << " ";
52 reverse(v
.begin()+i
, v
.end());
53 if (llevo
+1 < n
) cout
<< llevo
+1 << " ";
54 reverse(v
.begin()+llevo
, v
.end());